package tom.vertx.core.demo12;

import io.vertx.core.buffer.Buffer;
import io.vertx.core.parsetools.RecordParser;

/**
 * 协议解析器
 *
 * @author ZHUFEIFEI
 */
public class RecordParserDemo {
  public static void main(String[] args) {
    //根据换行符解析
//    RecordParser parser = RecordParser.newDelimited("\n", out -> {
//      System.out.println(out.toString());
//    });
    //每4个字节作为一个块作为内容
    RecordParser parser = RecordParser.newFixed(4, out -> {
      System.out.println(out.toString());
    });
    parser.handle(Buffer.buffer("HELLO\nHOW ARE Y"));
    parser.handle(Buffer.buffer("OU?\nI AM"));
    parser.handle(Buffer.buffer("DOING OK"));
    parser.handle(Buffer.buffer("\n"));
  }
}
